package  com.pcbly.web.business.publicinfo;

/**
* @author carl.song
* Copyright (c) 2010 Lightsoft, International.
* All rights reserved.
*
*/

import java.util.HashMap;
import java.util.List;

import com.pcbly.web.persistence.publicinfo.ArticleCommentDao;
import com.pcbly.web.persistence.table.ColumnDao;
import com.pcbly.web.bean.publicinfo.ArticleCommentBean;
import com.pcbly.web.bean.table.ColumnBean;
import com.pcbly.web.business.BaseServiceImp;
import com.pcbly.web.components.hibernate.support.Page;
import com.pcbly.web.components.form.AbstractAnalyseCommonDataExt;
import com.pcbly.web.components.form.AnalyseCommonDataExtCreate;
import com.pcbly.web.components.form.AnalyseCommonDataExtEdit;
import com.pcbly.web.components.form.AnalyseCommonDataExtView;

 
public class ArticleCommentServiceImp extends BaseServiceImp<ArticleCommentBean> implements ArticleCommentService {
	 public ArticleCommentServiceImp() {
		super();
		// TODO Auto-generated constructor stub
	}
	private ArticleCommentDao articleCommentDao;
	
	private ColumnDao columnDao;

	public void setColumnDao(ColumnDao columnDao) {
		this.columnDao = columnDao;
	}
	
	public void setArticleCommentDao(ArticleCommentDao articleCommentDao) {
		this.articleCommentDao = articleCommentDao;
	}
	
	@Override
	public ArticleCommentBean getArticleCommentBeanById(String id) throws Exception {
		// TODO Auto-generated method stub
		return articleCommentDao.get(ArticleCommentBean.class,id);
	}
	
	@Override
	public void removeArticleCommentBeanById(String id) throws Exception{
		articleCommentDao.removeArticleCommentBeanById(id);
	}
	
	@Override
	public void removeArticleCommentBeanByIds(String ids) throws Exception{
		articleCommentDao.removeArticleCommentBeanByIds(ids);
	}
	
	
	@Override
	public ArticleCommentBean saveArticleCommentBean(ArticleCommentBean publicinfo) throws Exception{
		return articleCommentDao.saveArticleCommentBean(publicinfo);
	}
	
	@Override
	public ArticleCommentBean updateArticleCommentBean(ArticleCommentBean publicinfo) throws Exception{
		articleCommentDao.saveObject( publicinfo);
		return publicinfo;
	}
	public Page<ArticleCommentBean>  findArticleCommentBeanByCond(ArticleCommentBean bean,
			Page<ArticleCommentBean> page, String orderByName, boolean asc)
			throws Exception{
		return articleCommentDao.findArticleCommentBeanByCond(
				bean, page, orderByName, asc);
	}
	
	@Override
	public String findArticleCommentBeanExtCreate(String tableName) throws Exception {
		// TODO Auto-generated method stub
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtCreate();
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public String findArticleCommentBeanExtEdit(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		List<HashMap<String, String>> dataList = articleCommentDao
				.findCommnonDataBeanExt(tableName, id);
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtEdit();
		common.setDataList(dataList);
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public String findArticleCommentBeanExtView(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		List<HashMap<String, String>> dataList = articleCommentDao
				.findCommnonDataBeanExt(tableName, id);
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtView();
		common.setDataList(dataList);
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public void saveArticleCommentBeanExt(String sql) throws Exception {
		// TODO Auto-generated method stub
		articleCommentDao.saveCommnonDataBeanExt(sql);
	}

	@Override
	public boolean getHasArticleCommentBeanExtData(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		return articleCommentDao.getHasCommnonDataBeanExt(tableName, id);
	}
}
